import Vue from 'vue'
// 使用jsencrypt插件实现RSA非对称加密
import { JSEncrypt } from 'jsencrypt'

let publicKey = `-----BEGIN PUBLIC KEY-----
MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC8YQVnNp1D1MssDJ+xqMnP50kB
Z07H3BWO9fBxNn9IEuTfaBCdDch89ZU5v5zQvoz5g66kI4Lub31KtzrswchSsEFm
nNbTCrjNJNaZ36NysmvZVQ+1FdzhxxCRKV5ElpenJqxUpg9DyE9DGEX+hHkfa4Pf
ZECdn8qEy98RABd13QIDAQAB
-----END PUBLIC KEY-----`  // 从后台获取公钥，这里省略，直接赋值
let encryptor = new JSEncrypt()  // 新建JSEncrypt对象
encryptor.setPublicKey(publicKey)  // 设置公钥
Vue.prototype.$encryptor = encryptor
// 使用方法: console.log(this.$encryptor.encrypt('pwd'))
export default encryptor